// Copyright (C) 2005 Outtask, Inc. All Rights Reserved.

function menuOpenWindow(url, title)
{
	window.open(url,title,'width=640,height=480,scrollbars,toolbar,resizable');
}

// the original menu code from webreference defines the popUp() function
// in such a manner that the menu code gets accessed before any other code
// in the HREF's that call the menu.  However, we need to capture which 
// day the user has clicked on.	 See inc_cal_month_functions.asp for better
// comments.


function logOut() {
	var msg = OTGetUserMessage("SmallJS", 'AreYouSureYouWantToLogout');
	if (confirm(msg)) {
		window.location.href="/errors/loggedout.asp"
	}
}  

function getScreenWidth()
{
	var screenWidth = screen.width
	return screenWidth
}

// Duplicated from drawSupportFooter when help links were moved to menu
var winSupportCenter
function openSupport(pageRef)
{
	if (!winSupportCenter || winSupportCenter.closed)
	{
		var screenLeft = screen.width/2 - 750
		var screenTop = screen.height/2 - 550
		var strAttributes = "width=750,height=550,left=" + screenLeft + ",top=" + screenTop + ",scrollbars,resizable,location,status,toolbar"
		winSupportCenter = window.open("/help/help_frame.asp?" + pageRef,"winSupportCenter",strAttributes)
	}
	else
	{
		winSupportCenter.location.href = "/help/help_frame.asp?" + pageRef
		winSupportCenter.focus()
	}
}

	// Parameters for Expense Admin window
	var expenseWinWidth = (screen.availWidth <= 1024) ? 780 : screen.availWidth - (screen.availWidth/4)
	var expenseWinHeight = (screen.availHeight <= 768) ? 510 : screen.availHeight - (screen.availHeight/4)
	var expenseWinText = 'width=' + expenseWinWidth + ',height=' + expenseWinHeight + ',top=' + (((screen.availHeight - expenseWinHeight)/2) - 20) + ',left=' + (((screen.availWidth - expenseWinWidth)/2) - 5) + ',menubar=no,scrollbars=yes,toolbar=yes,resizable=yes'

	function qMenu_search()
	{
		var server = otHierServer;

		if (document.layers)
		{
			var frmQMenu = document.overDiv.document.frmQMenu;
		}
		else
		{
			var frmQMenu = document.frmQMenu;
		}

		var strSearchBox = frmQMenu.searchString;
		var searchType = frmQMenu.qMenuSearchType.options[frmQMenu.qMenuSearchType.options.selectedIndex].value;

		if (strSearchBox.value == '' || strSearchBox.value == 'enter search values')
		{
			alert('You did not type anything into the search box.\n\nPlease enter a value in the search textbox and click "Search".');
			strSearchBox.focus();
		}
		else
		{
			if (searchType == "CAL")
			{
				document.location.href = server + "/calendar_search.asp?searchstring=" + escape(strSearchBox.value)
				return false
			}
			else
			{
				if (searchType == "CON")
				{
					frmQMenu.action = server + "/contacts/view_contacts.asp?pagetab=3"
				}
				else
				{
					frmQMenu.action = server + "/people_finder.asp"
				}
				frmQMenu.submit();
			}
		}
	}

	function qMenukeycheck(e)
	{
		if ((document.layers) && e.which == 13) qMenu_search();
		else if (document.all && window.event.keyCode == 13) qMenu_search();
		else if ((document.getElementById) && !(document.all) && e.keyCode == 13) qMenu_search();
		else return
	}

	function popup_vinnet_administrator(url) {
		var expenseWinWidth = (screen.availWidth <= 1024) ? 780 : screen.availWidth - (screen.availWidth/4);
		var expenseWinHeight = (screen.availHeight <= 768) ? 510 : screen.availHeight - (screen.availHeight/4);
		var expenseWinText = 'width=' + expenseWinWidth + ',height=' + expenseWinHeight + ',top=' + (((screen.availHeight - expenseWinHeight)/2) - 20) + ',left=' + (((screen.availWidth - expenseWinWidth)/2) - 5) + ',menubar=no,scrollbars=yes,toolbar=yes,resizable=yes';
		window.open(url,"ExpenseAdministration",expenseWinText);
	}
	
	function launchVinHelp() {
		if (typeof('popupWindow') != 'undefined') {
			popupWindow('/common/LaunchVinnetHelp.asp','vinhelp',1,1);
		}
		else {
			window.open('/common/LaunchVinnetHelp.asp','vinhelp','height=1,width=1');
		}
	}

	function openAssociatedTrip(requestType) {
		var http = new HttpRequest();
		http.oncomplete = function(status, data) {
			if (status == 200) {
				if (data != '') {
					if (data != 0) {
						if (requestType == 'request')
						{
							viewEvent("approval", data, "", false, true)
						}
						else
						{
							viewEvent('itin', data, '', false, true);
						}
					}
				}
				else {
					//I asked and was told that GSA is not localized
					//We would need to load user messages into the TravelManagerFrame for those to work
					CNQR.MessageBox.alert("No associated trip found. Please select a Travel Authorization and try again."
                  , { title: "Travel Voucher and Authorization System Message" });
				}
			}
		}						
			
		var url = "/TravelManagerTA.asp?tripquery=1";
		http.makeRequest(url);		
	
	}

//</script>